Skip to content

fix(agent-framework): give each add_memory call its own document - #1751

Closed
harshitgavita-07 wants to merge 2 commits into
supermemoryai:mainfrom
harshitgavita-07:harshitgavita-07-patch-1
Closed

harshitgavita-07 wants to merge 2 commits into
supermemoryai:mainfrom
harshitgavita-07:harshitgavita-07-patch-1

Conversation

@harshitgavita-07

Copy link
Copy Markdown

Problem

SupermemoryTools.add_memory in agent-framework-python passes custom_id=self._connection.custom_id (conversation_<id>) on every call.

In Supermemory a stable customId identifies one document, and re-adding under it updates that document (see the customId notes in the ingest docs). So with this tool:

  • the second add_memory call in a conversation replaces the first remembered fact instead of adding a new one, and
  • every tool-saved fact shares an id with the conversation transcript that the middleware and context provider save under the same connection.custom_id, so they overwrite each other.

supermemory_openai's add_memory does not pass a custom_id, so each fact is its own document there. This makes the agent-framework tool match.

Fix

Drop custom_id from the add_memory tool call. connection.custom_id is unchanged and still used for conversation capture.

Test

New TestAddMemoryDocumentIdentity records the arguments of two add_memory calls and asserts neither reuses connection.custom_id. It fails on main and passes with this change. Full package suite: 59 passed (58 existing plus the new one).

I did not run this against the live API. The overwrite behavior comes from the documented customId semantics, not from a live reproduction.

Clarified memory handling by removing custom_id in memory addition.
…ument id

Add tests to ensure unique document IDs for memory entries.
@MaheshtheDev

Copy link
Copy Markdown
Member

🤖 AI-assisted triage, reviewed by @MaheshtheDev.

Thanks! On v5, add_memory appending to the conversation document is intended (see the agent-framework v5 migration), so we're closing this one.

graphite-app Bot pushed a commit that referenced this pull request Oct 14, 2026
…ppers (#1799)

Bundles 10 community fixes for the Python wrappers, each commit kept with its original author. Ships supermemory-openai-sdk 1.0.10, supermemory-cartesia 0.1.5 and supermemory-pipecat 0.1.5.

- openai-sdk-python: shared OpenAI clients no longer leak memories across tenants (#1503), memory search fails open instead of crashing the chat (#1288), the requests fallback runs off the event loop (#1660), get_profile works for users with no memories (#1759).
- cartesia: the wrapped agent runs exactly once per event (#1280, #1670), plain-string and chunk-only search results are kept (#1683, #1693).
- pipecat: memory text stays literal when replacing the injected block (#1647), `InputParams` is exported from the package root (#1575).
- #1503 was hand-ported onto main's newer middleware. #1751 is left out: the v5 agent-framework migration (#1786) appends to the conversation document by design.

Co-Authored-By: abhinav7x94 <204053250+abhinav7x94@users.noreply.github.com>
Co-Authored-By: shamAnimates <145093437+shamAnimates@users.noreply.github.com>
Co-Authored-By: aloktripathi1 <142301030+aloktripathi1@users.noreply.github.com>
Co-Authored-By: Cintu07 <178455858+Cintu07@users.noreply.github.com>
Co-Authored-By: Atharvsinh-codez <201381760+Atharvsinh-codez@users.noreply.github.com>
Co-Authored-By: abhay-codes07 <182421137+abhay-codes07@users.noreply.github.com>
Co-Authored-By: nkootstra <545768+nkootstra@users.noreply.github.com>
Co-Authored-By: Agnik47 <140933190+Agnik47@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants